package cn.tramy.pinxian.common.handler.processor

import org.junit.jupiter.api.Assertions

internal class DefaultAnnotationHandlerProcessorTest {
    private val annotationHandlerProcessor = DefaultAnnotationHandlerProcessor()


    @org.junit.jupiter.api.Test
    fun process() {

        val eventHandler = TestEventHandler()
        val handlers = this.annotationHandlerProcessor.process(eventHandler, TestHandler::class.java)

        handlers.forEach { println(it) }

        Assertions.assertTrue(handlers.size==1)
        handlers.first().let { Assertions.assertTrue(it.eventType==TestEvent::class.java) }

        Assertions.assertTrue(handlers.first().async)


    }


}


class TestEvent


class TestEventHandler {

    @TestHandler(async = true)
    fun process(event: TestEvent) {

    }
}

@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.FUNCTION)
annotation class TestHandler(val async: Boolean = false)